// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0

OtherComp := Rectangle {
    property <string> t <=> text.text;
    property <string> get_text <=> text.text;
    text := Text {
        text: "to be overridden";
    }
    property <int> some_value: 42;
    property <int> some_value_alias <=> some_value;
}

TestCase := Rectangle {

    property <string> text1: "Hello";
    property <string> text2: "Blah";
    property <string> ti1_text: ti1.text;
    property <string> ti2_text: ti2.text;
    property <string> text_item_text: text_item.text;
    property <string> othercomp_t: "real value";
    property <string> othercomp_get_text: other_comp.get_text;
    property <int> othercomp_some_value;
    property <int> othercomp_some_value_alias <=> other_comp.some_value_alias;
    property <int> othercomp_some_value_alias2;

    ti1 := TextInput {
        text <=> text1;
    }

    ti2 := TextInput {
        text <=> text_item.text;
    }

    text_item := Text {
        text: text2;
    }

    Text {
        text <=> text1;
    }

    other_comp := OtherComp {
        t <=> root.othercomp_t;
        some_value <=> othercomp_some_value;
        some_value_alias <=> othercomp_some_value_alias2;
    }

    callback set_ti1(string);
    set_ti1(a) => { ti1.text = a; }
    callback set_ti2(string);
    set_ti2(a) => { ti2.text = a; }
}


/*

```rust
let instance = TestCase::new().unwrap();
assert_eq!(instance.get_text1(), slint::SharedString::from("Hello"));
assert_eq!(instance.get_text2(), slint::SharedString::from("Blah"));
assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Hello"));
assert_eq!(instance.get_ti2_text(), slint::SharedString::from("Blah"));
assert_eq!(instance.get_text_item_text(), slint::SharedString::from("Blah"));
assert_eq!(instance.get_othercomp_t(), instance.get_othercomp_get_text());
assert_eq!(instance.get_othercomp_t(), slint::SharedString::from("real value"));
assert_eq!(instance.get_othercomp_get_text(), slint::SharedString::from("real value"));

instance.set_text1(slint::SharedString::from("Text1New"));
instance.set_text2(slint::SharedString::from("Text2New"));
assert_eq!(instance.get_text1(), slint::SharedString::from("Text1New"));
assert_eq!(instance.get_text2(), slint::SharedString::from("Text2New"));
assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Text1New"));
assert_eq!(instance.get_ti2_text(), slint::SharedString::from("Text2New"));
assert_eq!(instance.get_text_item_text(), slint::SharedString::from("Text2New"));

instance.invoke_set_ti1(slint::SharedString::from("Hallo"));
instance.invoke_set_ti2(slint::SharedString::from("Bonjour"));
assert_eq!(instance.get_text1(), slint::SharedString::from("Hallo"));
assert_eq!(instance.get_text2(), slint::SharedString::from("Text2New"));
assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Hallo"));
assert_eq!(instance.get_ti2_text(), slint::SharedString::from("Bonjour"));
assert_eq!(instance.get_text_item_text(), slint::SharedString::from("Bonjour"));

assert_eq!(instance.get_othercomp_some_value(), 0);
assert_eq!(instance.get_othercomp_some_value_alias(), 0);
assert_eq!(instance.get_othercomp_some_value_alias2(), 0);
instance.set_othercomp_some_value(88);
assert_eq!(instance.get_othercomp_some_value(), 88);
assert_eq!(instance.get_othercomp_some_value_alias(), 88);
assert_eq!(instance.get_othercomp_some_value_alias2(), 88);
instance.set_othercomp_some_value_alias(81);
assert_eq!(instance.get_othercomp_some_value(), 81);
assert_eq!(instance.get_othercomp_some_value_alias(), 81);
assert_eq!(instance.get_othercomp_some_value_alias2(), 81);
instance.set_othercomp_some_value_alias2(1);
assert_eq!(instance.get_othercomp_some_value(), 1);
assert_eq!(instance.get_othercomp_some_value_alias(), 1);
assert_eq!(instance.get_othercomp_some_value_alias2(), 1);

```



```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert_eq(instance.get_text1(), slint::SharedString("Hello"));
assert_eq(instance.get_text2(), slint::SharedString("Blah"));
assert_eq(instance.get_ti1_text(), slint::SharedString("Hello"));
assert_eq(instance.get_ti2_text(), slint::SharedString("Blah"));
assert_eq(instance.get_text_item_text(), slint::SharedString("Blah"));
assert_eq(instance.get_othercomp_t(), instance.get_othercomp_get_text());
assert_eq(instance.get_othercomp_t(), slint::SharedString("real value"));
assert_eq(instance.get_othercomp_get_text(), slint::SharedString("real value"));


instance.set_text1(slint::SharedString("Text1New"));
instance.set_text2(slint::SharedString("Text2New"));
assert_eq(instance.get_text1(), slint::SharedString("Text1New"));
assert_eq(instance.get_text2(), slint::SharedString("Text2New"));
assert_eq(instance.get_ti1_text(), slint::SharedString("Text1New"));
assert_eq(instance.get_ti2_text(), slint::SharedString("Text2New"));
assert_eq(instance.get_text_item_text(), slint::SharedString("Text2New"));

instance.invoke_set_ti1(slint::SharedString("Hallo"));
instance.invoke_set_ti2(slint::SharedString("Bonjour"));
assert_eq(instance.get_text1(), slint::SharedString("Hallo"));
assert_eq(instance.get_text2(), slint::SharedString("Text2New"));
assert_eq(instance.get_ti1_text(), slint::SharedString("Hallo"));
assert_eq(instance.get_ti2_text(), slint::SharedString("Bonjour"));
assert_eq(instance.get_text_item_text(), slint::SharedString("Bonjour"));

assert_eq(instance.get_othercomp_some_value(), 0);
assert_eq(instance.get_othercomp_some_value_alias(), 0);
assert_eq(instance.get_othercomp_some_value_alias2(), 0);
instance.set_othercomp_some_value(88);
assert_eq(instance.get_othercomp_some_value(), 88);
assert_eq(instance.get_othercomp_some_value_alias(), 88);
assert_eq(instance.get_othercomp_some_value_alias2(), 88);
instance.set_othercomp_some_value_alias(81);
assert_eq(instance.get_othercomp_some_value(), 81);
assert_eq(instance.get_othercomp_some_value_alias(), 81);
assert_eq(instance.get_othercomp_some_value_alias2(), 81);
instance.set_othercomp_some_value_alias2(1);
assert_eq(instance.get_othercomp_some_value(), 1);
assert_eq(instance.get_othercomp_some_value_alias(), 1);
assert_eq(instance.get_othercomp_some_value_alias2(), 1);
```


```js
let instance = new slint.TestCase({});
assert.equal(instance.text1, "Hello");
assert.equal(instance.text2, "Blah");
assert.equal(instance.ti1_text, "Hello");
assert.equal(instance.ti2_text, "Blah");
assert.equal(instance.text_item_text, "Blah");
assert.equal(instance.othercomp_t, instance.othercomp_get_text);
assert.equal(instance.othercomp_t, "real value");
assert.equal(instance.othercomp_get_text, "real value");

instance.text1 = "Text1New";
instance.text2 = "Text2New";
assert.equal(instance.text1, "Text1New");
assert.equal(instance.text2, "Text2New");
assert.equal(instance.ti1_text, "Text1New");
assert.equal(instance.ti2_text, "Text2New");
assert.equal(instance.text_item_text, "Text2New");

instance.set_ti1("Hallo");
instance.set_ti2("Bonjour");
assert.equal(instance.text1, "Hallo");
assert.equal(instance.text2, "Text2New");
assert.equal(instance.ti1_text, "Hallo");
assert.equal(instance.ti2_text, "Bonjour");
assert.equal(instance.text_item_text, "Bonjour");

assert.equal(instance.othercomp_some_value, 0);
assert.equal(instance.othercomp_some_value_alias, 0);
assert.equal(instance.othercomp_some_value_alias2, 0);
instance.othercomp_some_value = 88;
assert.equal(instance.othercomp_some_value, 88);
assert.equal(instance.othercomp_some_value_alias, 88);
assert.equal(instance.othercomp_some_value_alias2, 88);
instance.othercomp_some_value_alias = 81;
assert.equal(instance.othercomp_some_value, 81);
assert.equal(instance.othercomp_some_value_alias, 81);
assert.equal(instance.othercomp_some_value_alias2, 81);
instance.othercomp_some_value_alias2 = 1;
assert.equal(instance.othercomp_some_value, 1);
assert.equal(instance.othercomp_some_value_alias, 1);
assert.equal(instance.othercomp_some_value_alias2, 1);
```

*/
